<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <input id="button_open" type="button" value="开启" />
  <input id="button_close" type="button" value="关闭" />

  <script>
    let button_open = document.getElementById("button_open")
    let button_close = document.getElementById("button_close")
    let timer = null
    button_open.onclick = function () {
      timer = setInterval(() => {
        console.log("aa");

      }, 1000);
    }
    button_close.onclick = function () {
      clearInterval(timer)
    }



  </script>
</body>

</html>